/*
 * Copyright (C) 2022 KylinSoft Co., Ltd.
 *
 * This program is free software: you can redistribute it and/or modify it under
 * the terms of the GNU General Public License as published by the Free Software
 * Foundation, either version 3 of the License, or (at your option) any later
 * version.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along with
 * this program. If not, see <https://www.gnu.org/licenses/>.
 */

#ifndef TABLETDESKTOPBACKEND_H
#define TABLETDESKTOPBACKEND_H

#include "types.h"
#include <QObject>

class DesktopItemLoader;
namespace UKUI {
class DesktopDataProviderPrivate;
class DesktopDataProvider : public QObject
{
    Q_OBJECT
    Q_DECLARE_PRIVATE(DesktopDataProvider)
    Q_DISABLE_COPY(DesktopDataProvider)

public:
    explicit DesktopDataProvider();
    ~DesktopDataProvider();

public:
    QMap<int, BaseItem *> getAllItems() const;
    QMap<int, QList<int>> getAllItemIdsInPage() const;
    QMap<int, QList<QList<int>>> getAllItemIdsInSet() const;

    QList<ItemId> getAppIdListAccordingCategory(BaseItem::Categories type);
    QList<ItemId> getAllAppIdList();

    void addHomeScreenPage();
    void deleteHomeScreenPage();
    void updateHomeScreenPageIds(int page, const QList<int> &ids);
    void setSetName(int setId, const QString &name);

    void createGroup(int groupId, const QString &groupName, const QList<int> &itemIds);
    void updateSet(int setId, const QList<QList<int>> &ids);
    void removeGroup(int groupId);

    void uninsatllApp(const QString &desktopFile);
    void replaceGroupIdWithAppId(int groupId, int appId);
    void updateWidgetState(int state);

signals:
    void itemAdded(int id, int page);
    void taskbarAppIdAdded(int itemId, int insertPosIndex);
    void itemRemovedFromSet(int itemId, int setId);
    void itemRemovedFromHomeScreen(int itemId, int page);
    void appIdTakedFromSet(int itemId, int setId);
    void appIdTakedFromHomeScreen(int itemId, int setId);
    void appIdTakedFromTaskbar(int itemId);

    void iconThemeChanged();

    void taskbarAppIdPosExchanged(const QList<int> &appIdList);
    void moveAppIdToHomeScreen(int itemId, int pageId);
    void taskBarAppChanged(struct appChangePositionInfo &appChangePosition);
    void appCategoryChanged(const quint32 id, const QList<int> newCategory);
    void eduCategoryChanged();


private:
    DesktopDataProviderPrivate *d_ptr;
};

}

#endif // TABLETDESKTOPBACKEND_H
